# 使用多阶段构建减少最终镜像体积

# 阶段1：构建环境
FROM golang:1.24-alpine AS builder
# 设置 GOPROXY 并验证
ENV GOPROXY=https://goproxy.cn,direct
RUN echo "GOPROXY value: $GOPROXY"
RUN go install github.com/air-verse/air@latest
WORKDIR /paper-pro

# 阶段2：运行环境
FROM golang:1.24-alpine
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories \
    && apk add --no-cache git bash
COPY --from=builder /go/bin/air /usr/local/bin/air
WORKDIR /paper-pro/app/assistant/rpc/dev
EXPOSE 8080
CMD ["air", "-c", ".air.toml"]
